import java.util.*;
class Animal{
    public String name;
    public Animal(String name){
        this.name=name;
    }
}
interface IFly{
    void fly();
}
interface IRun{
    void run();
}
interface ISwimming{
    void swimming();
}
class Cat extends Animal implements IRun{
    public Cat(String name){
        super(name);
    }
    @Override
    public void run() {
        System.out.println(name+"会跑");
    }
}
class Fish extends Animal implements ISwimming{
    public Fish(String name){
        super(name);
    }

    @Override
    public void swimming() {
        System.out.println(this.name+"会游泳");
    }
}
class Swan extends Animal implements IRun, ISwimming, IFly{
    public Swan(String name){
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name+"会跑");
    }

    @Override
    public void swimming() {
        System.out.println(name+"会游泳");
    }

    @Override
    public void fly() {
        System.out.println(name+"会飞");
    }
}
class Student {
    public String name;
    public int age;
    public int score;

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

}
class ageFunc implements Comparator<Student>{

    @Override
    public int compare(Student o1, Student o2) {
        return o1.age-o2.age;
    }
}
public class TestDemo1 {
    public static void main2(String[] args) {
        Student[] student=new Student[3];
        student[0]=new Student("张三",25,92);
        student[1]=new Student("李四",27,95);
        student[2]=new Student("王五",21,78);
        ageFunc ageFunc=new ageFunc() ;
        Arrays.sort(student,ageFunc);
        System.out.println(Arrays.toString(student));
    }
    public static void main1(String[] args) {
        Cat cat=new Cat("小猫猫");
        Animal animal1=new Fish("小鱼鱼");
        Animal animal2=new Swan("小飞鹅");
        cat.run();
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        Player player1=new Player("张三",21);
        Player player2=(Player) player1.clone();
        System.out.println("player1的名字和年龄:"+player1.name+player1.age[0]);
        System.out.println("player2的名字和年龄:"+player2.name+player2.age[0]);
        System.out.println(player1.name==player2.name);
        System.out.println(player1.age[0]==player2.age[0]);
        player2.name="李四";
        player2.age[0]=25;
        System.out.println(player1.name+player1.age[0]);
        System.out.println(player2.name+player2.age[0]);
    }
}


class Player implements Cloneable{
    protected String name;
    int []age=new int[1];
    public Player(String name,int age){
        this.name=name;
        this.age[0]=age;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

//滑动窗口+双指针
    public int characterReplacement(String s, int k) {
        char[]array=s.toCharArray();
        int left=0;
        int right=0;
        int length=array.length;
        int []nums=new int[26];
        int max=0;
        while(right<length){
            //求每个字母出现的次数(窗口)
            nums[array[right]-'A']++;
            //求出固定窗口下出现最多的字母字符
            max=Math.max(max,nums[array[right]-'A']);
            //求该固定窗口大小
            if(right-left+1-max>k){
                nums[array[left]-'A']--;
                left++;
            }
            right++;
        }
        return right-left;
    }

    public boolean checkInclusion(String s1, String s2) {
        char[]ch1=s1.toCharArray();
        char[]ch2=s2.toCharArray();
        int []array1=new int[26];
        int []array2=new int [26];
        int n=ch1.length;
        int m=ch2.length;
        if(n>m){
            return false;
        }
        for(int i=0;i<n;i++){
            array1[ch1[i]-'a']++;
            array2[ch2[i]-'a']++;
        }
        if(Arrays.equals(array1,array2)){
            return true;
        }
        int left=0;
        for(int i=n;i<m;i++){
            array2[ch2[i]-'a']++;
            array2[ch2[left]-'a']--;
            left++;
            if(Arrays.equals(array1,array2)){
                return true;
            }
        }
        return false;
    }
}
